package group.Config;


import group.FactoryUtil.ConnectionFactoryUtil;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Ulegal on 2017/12/13.
 */
@Configuration
public class RabbitmqConfig {

    @Bean
    public RabbitTemplate rabbitTemplate() {
        return ConnectionFactoryUtil.getRabbitTemplate();
    }

    @Bean
    public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
        return ConnectionFactoryUtil.getRabbitListenerContainerFactory();
    }


//    @Bean
//    public Queue helloQueue() {
//        return new Queue("rabbitmqkey");
//    }
    /**
     * 跨域
     * @return WebMvcConfigurer
     */
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**");
            }
        };
    }



}
